package exam.ccwtest;

import android.app.*;
import android.os.*;
import android.view.*;
import android.view.View.*;
import android.widget.*;

public  class c06_Fruit extends Activity {
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.c06_fruit);
		
		/* 1번째 방법
		Button btnApple = (Button)findViewById(R.id.apple);
		btnApple.setOnClickListener (new Button.OnClickListener() {
			public void onClick (View v) {
				TextView textFruit = (TextView)findViewById(R.id.fruit);
				textFruit.setText("Apple");
			}
		});
		
		Button btnOrange = (Button)findViewById(R.id.orange);
		btnOrange.setOnClickListener(new Button.OnClickListener() {
			public void onClick (View v) {
				TextView textFruit = (TextView)findViewById(R.id.fruit);
				textFruit.setText("오랜지");
			}
		});
		*/
		
		/* 2번째 방법
		Button btnApple = (Button)findViewById(R.id.apple);
		btnApple.setOnClickListener(this);
		Button btnOrange = (Button)findViewById(R.id.orange);
		btnOrange.setOnClickListener (this);		
	}
	
	public void onClick (View v) {
		TextView textFruit = (TextView)findViewById(R.id.fruit);
		switch (v.getId()) {
		case R.id.apple:
			textFruit.setText("애플2");
			break;
		case R.id.orange:
			textFruit.setText("오렌지2");
			break;
		}
		*/
		
		findViewById(R.id.apple).setOnClickListener(mClickListener);
		findViewById(R.id.orange).setOnClickListener(mClickListener);
	}
	
	Button.OnClickListener mClickListener = new View.OnClickListener() {
		
		public void onClick(View v) {
			TextView textFruit = (TextView)findViewById(R.id.fruit);
			switch (v.getId()) {
			case R.id.apple:
				textFruit.setText("Apple3");
				break;
			case R.id.orange:
				textFruit.setText("Orange3");
				break;
			}			
		}
	};
}





